<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>Title</title>
</head>
<script>
    //安全退出按钮得切换显示
    $(function () {
        $("#userspan").click(function () {
            $("#menu").toggle();
        })
    })
    /*用户退出*/
    function out() {
        layer.confirm('确定要退出吗？', {
            btn: ['确定','取消'] //按钮
        }, function(){
            location.href="${pageContext.request.contextPath}/UserServlet/out";
        });
    }
    /*判断用户是否登录*/
    function checkLogin(i) {
        var user = $("#userId").val();
        console.log(user)
        if (user==""){
            show('',550,500,'${pageContext.request.contextPath}/login.jsp')
        }else {
            if (i==1){
                window.location.href="${pageContext.request.contextPath}/member.jsp";
            }else if (i==2) {
                window.location.href="${pageContext.request.contextPath}/ProductServlet/gotoMenu";
            }else {
               return  true;
            }
        }
    }
</script>
<div class="m-top">
    <input type="hidden" id="userId" value="${user.userId}">
    <div class="box" id="j-top-nav">
        <a href="${pageContext.request.contextPath}/main.jsp"><div class="logo fl"></div> </a>
        <a href="${pageContext.request.contextPath}/ProductServlet/gotoMenu" ><div class="menu fl"  style="width:100px">
            菜单
        </div> </a>
        <div class="separator fl"></div>
        <a href="#" onclick="checkLogin(1)"><div class="menu fl" style="width:100px">
            会员中心
        </div> </a>
        <input type="hidden" id="j-is-login" value="false" />
        <div class="clien fl">
                <a href="#" id="userspan" >${user.userName}<img src="${pageContext.request.contextPath}/images/common/arrow-down.png" align="center" />
                </a>
            <dl style="display: none; background-color: white;" id="menu"> <!-- 二级菜单 -->
                <dd><a href="javascript:out()">安全退出</a></dd>
            </dl>
        </div>
        <div class="start fr" id="j-start-order"
             onclick="checkLogin(2)">
            立即点餐
        </div>
    </div>
</div>

